### Project 9 Traffic Light **1.Description** Today, we will meet a friend. He has three expressions and often instruct us to obey the traffic rules. Do you know who he is? Let’s explore together! **Task analysis** | Sensor | Red, Yellow and Green Module | | ---------- | ---------------------------------------------------------- | | Role | Sasha/convertible 3 | | Background | Urban | | Result | People will stop at red light and walk when it turns green | **2.Traffic Light Module Introduction** ![](media/image-20251208114233973.png) There are 6 ports on the traffic light module, including 3 GND ports, which are connected. The module comes with 3 LED lights in red, yellow and green, among which G controls the green light, Y controls the yellow light, and R controls the red light . We can control the 3 LEDs on and off on the module , and simulate the roadside traffic lights flashing. **Specifications** - Operating voltage: DC 3.3V-5V - Control port:Digital port - Dimension: 42mm * 47mm * 12mm - Weight: 5.7g - Environmental protection attributes: ROHS **3.Components Needed** | Control Board * 1 | USB Cable*1 | Connection Wires | Traffic Light Module*1 | | -------------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- | | ![](media/image-20251208114334262.png) | ![](media/image-20251208114340178.png) | ![](media/image-20251208114346249.png) | ![](media/image-20251208114352211.png) | **4.Connection Diagram** ![](media/image-20251208114416128.png) **5.Test Program** 1.Open“KidsBlock”software to create a new project. 2.Delete the beetle role. 3.Select “Urban”:click the background library icon![](media/image-20251208114544028.png)in the lower right corner to select Urban. ![](media/image-20251208114617055.png) 4.Select Sasha/convertible 3, as shown below: ![](media/image-20251208114639338.png) 5.Flow Chart ![](media/image-20251208114658356.png) 6.Build the program ①Select “Sasha”and build the program, as shown below: ![](media/image-20251208114742111.png) ②Select “convertible 3”and build the program, as shown below: ![](media/image-20251208114803238.png) **6.Test Result** Connect the wirings and the device then select the port, then click![](media/image-20251208115132226.png).If the green light on the traffic module is on, Sasha will walk across the road, and the green light will be off after 5s. Then the yellow light will flash for two times, and the red light will be on, convertible 3 will start to drive and turn off after 5s, as shown in the picture below: ![](media/image-20251208115149398.png) ![](media/image-20251208115156418.png) **7.Program Explanation** | Instruction | Function | | -------------------------------------- | ------------------------------------------------------------ | | ![](media/image-20251208115343559.png) | Initialize the red, yellow and green lights on the traffic light module | | ![](media/image-20251208115402842.png) | Turn on the green light and Sasha will move to the coordinate(X:-147,Y:-207) | | ![](media/image-20251208115430235.png) | Turn off the green light and the yellow light will flash for 2 times | | ![](media/image-20251208115446913.png) | After a delay of 5s, Sasha returns to its original position | | ![](media/image-20251208115501893.png) | 7s is the total time spent by the Sasha
Turn off the green and yellow light
Turn on the red light , convertible 3 will move to the coordinate(X:296,Y:-123)
Turn off the red light, convertible 3returns to its original position |